﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if DEVELOP
namespace Asset
{
    public class EditorAsyncAsset<T> : AsyncAsset<T> where T : UnityEngine.Object
    {
        public EditorAsyncAsset(string name, IAsyncBundle bundle) : base(name, bundle)
        {

        }

        protected override void initialize()
        {

        }

        public override IEnumerator doLoad()
        {
            if (this.Status == AsyncStatus.Waiting && this.Bundle.editorAsset != null)
            {
                this.asyncStatus = AsyncStatus.Finish;
                this.result = this.Bundle.editorAsset as T;
                if (this.result == null)
                {
                    this.result = UnityEditor.AssetDatabase.LoadAssetAtPath<T>(this.Bundle.URL);
                    this.Bundle.editorAsset = this.result;
                }
                this.invokeEvent();
                yield break;
            }
            else
            {
                yield return null;
            }
        }


    }

}
#endif